home *** CD-ROM | disk | FTP | other *** search
/ Pascal Super Library / Pascal Super Library (CW International)(1997).bin / LIBRARY / RTPC10 / JOKE.PAS < prev    next >
Pascal/Delphi Source File  |  1993-11-20  |  4KB  |  87 lines

  1. {
  2.   ┌────────┬──────────────────────────────────────────────────────┐
  3.   │Name    │ JOKE.PAS                                             │
  4.   ├────────┼──────────────────────────────────────────────────────┤
  5.   │Use     │ Just an example program for TP6 and above.           │
  6.   │        │ A TSR that prints HA! HA! every 10 seconds.          │
  7.   ├────────┼──────────────────────────────────────────────────────┤
  8.   │By      │ Rafe Aldridge - (C) Copyright 1993                   │
  9.   └────────┴──────────────────────────────────────────────────────┘
  10.   ┌───────────────────────────────────────────────────────────────┐
  11.   │ Please realise that this program present's an idea. No claim  │
  12.   │ is made that it is well written or cannot be improved upon    │
  13.   └───────────────────────────────────────────────────────────────┘
  14.   ┌───────────────────────────────────────────────────────────────┐
  15.   │ Rafe's TP Collection is SHAREWARE                             │
  16.   ├───────────────────────────────────────────────────────────────┤
  17.   │                                                               │
  18.   │ If you find any part of Rafe's TP Collection usefull then     │
  19.   │ please become a registered user by sending 10 Pounds Sterling │
  20.   │ to the address below. In return you will recieve the LATEST   │
  21.   │ FULL source code to ALL the units as well anything new.       │
  22.   │                                                               │
  23.   │ Please feel free to write with suggestions, ideas or money to │
  24.   │     Rafe Aldridge,                                            │
  25.   │     Street Farm,                                              │
  26.   │     Dereham Road,                                             │
  27.   │     Garvestone,                                               │
  28.   │     Norfolk.                                                  │
  29.   │     NR9 4QT                                                   │
  30.   │     ENGLAND                                                   │
  31.   │                                                               │
  32.   └───────────────────────────────────────────────────────────────┘
  33. }
  34.  
  35. { ---------------------------------------------------------------------- }
  36. { NOTES:                                                                 }
  37. { o A TP interrupt proc disables interrupts. Hence the need for an STI.  }
  38. { o An interrupt proc must not last more than 50mS. If it will last      }
  39. {   longer then a busy flag must be used to stop recursion.              }
  40. { o In order to avoid an attempt to reenter DOS only use a DOS function  }
  41. {   when DOS is idle. I don't think that TP write uses a DOS function    }
  42. {   but I included the busy code to show how it is done.                 }
  43. { o TP initalizes the DS register in the interrupt proc.                 }
  44. { ---------------------------------------------------------------------- }
  45.  
  46. {$M 1024,0,0} { reserve stack memory }
  47.  
  48. {$R-,S-,D-,L-} { turn off stack checking etc. }
  49.  
  50. Uses DOS; { library for getintvec and setintvec }
  51.  
  52. Const DELAY_TIME = 182; { delay_time = 18.2 * number of seconds }
  53.  
  54. Var CNT        : Word;    { counter }
  55.     TIM_VEC    : Pointer; { old timer routine }
  56.     DOS_SEG    : Word;    { segment and address for DOS BUSY flag }
  57.     DOS_BUSY   : Word;
  58.  
  59. Procedure CLOCK; Interrupt;
  60. Begin
  61.   Asm
  62.     PushF
  63.     Call DWord Ptr TIM_VEC { use built in assmblr to call old timer routine }
  64.   End;
  65.   If (CNT>DELAY_TIME) And (Mem[DOS_SEG:DOS_BUSY]=0) Then
  66.     Begin
  67.       Write (' HA! HA! ');
  68.       CNT:=0; { reset counter }
  69.     End;
  70.   Inc (CNT,1); { increment counter by 1 }
  71.   Asm
  72.     STI; { enable interrupts as TP proc turned em off }
  73.   End;
  74. End;
  75.  
  76. Begin
  77.   GetIntVec (8,TIM_VEC); { get old vector }
  78.   SetIntVec (8,@CLOCK);  { point vector to our routine }
  79.   Asm
  80.     Mov AH,$34 { get dos busy address }
  81.     Int $21
  82.     Mov DOS_SEG,ES
  83.     Mov DOS_BUSY,BX
  84.   End;
  85.   CNT:=0;
  86.   Keep(0);
  87. End.